<template>
  <div class="container">
    <div class="nav">
      <van-nav-bar title="待付款订单" @click-left="goBack">
        <template #left>
          <van-icon name="arrow-left" size="1rem" color="black" />
        </template>
      </van-nav-bar>
    </div>
    <div class="content">
      <div class="addressBox" @click="toAddress">
        <div class="addressLeft">
          <div v-if="!addressInfo">没有添加地址 点击新增</div>
          <div class="receiverInfo" v-if="addressInfo">
            {{ addressInfo.name }}
            <span>{{addressInfo.tel}}</span>
          </div>
          <div class="addressInfo" v-if="addressInfo">{{ addressInfo.address }}</div>
        </div>
        <div class="addressRight">
          <i class="iconfont icon-right" />
        </div>
      </div>
      <div class="detailBox">
        <div class="detailHeader">
          <van-tag type="danger">自营</van-tag>
          <span class="storeTitle">小米旗舰店</span>
        </div>
        <div class="detailContent">
          <img
            src="https://uniapp.b2b2c.niuteam.cn/upload/9/common/images/20200420/20200420115612158735497285781_mid.jpg"
            alt
          />
          <div class="detailContentRight">
            <span class="goodstTitle">向日葵花束生日配送鲜花速递 蓝色梦幻</span>
            <div>
              <span class="spec">配色/蓝色梦幻</span>
            </div>
            <div class="unitPrice">
              <span class="price">
                <span style="font-size:.75rem">￥</span>45.00
              </span>
              <span class="num">
                <span style="padding-right:2px">x</span>3
              </span>
            </div>
          </div>
        </div>
      </div>
      <ul class="amountBox">
        <li>
          <span>商品金额</span>
          <span>¥45.00</span>
        </li>
        <li>
          <span>运费</span>
          <span>¥0.00</span>
        </li>
      </ul>
    </div>

    <div class="footer">
      <div class="totalNum">共1件</div>
      <div class="summation">
        合计：
        <span class="totalAmount">¥45.00</span>
      </div>
      <button @click="submitOrder">提交订单</button>
    </div>
  </div>
</template>

<script>
import { Tag, NavBar, Icon } from "vant";
export default {
  components: {
    "van-nav-bar": NavBar,
    "van-tag": Tag,
    "van-icon": Icon
  },
  data() {
    return {
      addressInfo: null
    };
  },
  created() {
    const address = JSON.parse(sessionStorage.getItem("selectedAddress"));
    this.addressInfo = address;
  },
  methods: {
    submitOrder() {
      this.$router.push("/activity/sec-kill/pay");
    },
    goBack() {
      this.$router.push("/activity/sec-kill/detail");
    },
    toAddress() {
      this.$router.push(`/address/list?back=${this.$route.path}`);
    }
  }
};
</script>

<style lang="less">
.container {
  background-color: #f7f7f7;
  height: 100%;
}
.nav {
  height: 2.3rem;
}
.content {
  box-sizing: border-box;
  height: calc(100% - 5.1rem);
  padding: 0.4rem;
  overflow-y: scroll;
  .addressBox {
    background-color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem;
    .addressLeft {
      font-size: 0.7rem;
      .addressInfo {
        padding-top: 0.25rem;
      }
    }
  }

  .detailBox {
    margin-top: 0.4rem;
    background-color: white;
    padding: 0.6rem;
    .detailHeader {
      padding-bottom: 0.8rem;
      .storeTitle {
        padding-left: 0.4rem;
        font-size: 0.75rem;
        color: #666;
      }
    }
    .detailContent {
      display: flex;
      > img {
        border-radius: 0.4rem;
        width: 4.3rem;
        height: 4.3rem;
      }
      .detailContentRight {
        margin-left: 0.6rem;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        .goodstTitle {
          font-size: 0.7rem;
        }
        .spec {
          background-color: #fdfdfd;
          color: #b6b6b6;
          font-size: 0.65rem;
          padding: 0.2rem 0.4rem;
          border-radius: 0.2rem;
        }
        .unitPrice {
          .price {
            color: #ff335c;
            font-size: 1rem;
            font-weight: 700;
          }
          .num {
            padding: 0.4rem;
            color: #666;
            font-size: 0.8rem;
            font-weight: 400;
          }
        }
      }
    }
  }
  .amountBox {
    margin-top: 0.4rem;
    padding: 0.6rem;
    background-color: white;
    li {
      display: flex;
      justify-content: space-between;
      font-size: 0.7rem;
      &:nth-child(odd) {
        padding-bottom: 0.6rem;
      }
    }
  }
}

.footer {
  box-sizing: border-box;
  background-color: white;
  padding: 0 0.6rem;
  height: 2.8rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  .totalNum {
    color: #666;
    font-size: 0.7rem;
  }
  button {
    padding: 0.4rem 1rem;
    background-image: linear-gradient(to right, #ff99ae, #ff335c);
    border: none;
    color: white;
    border-radius: 0.8rem;
    font-size: 0.7rem;
    outline: none;
  }
  .summation {
    padding: 0 0.8rem;
    font-size: 0.85rem;
    .totalAmount {
      font-size: 1rem;
      color: #ff335c;
      font-weight: 700;
    }
  }
}
</style>